<?php
namespace App\Api\Transformers;


use App\SunPicture;
use League\Fractal\TransformerAbstract;
use App\PostComment;


class SunpictureContentTransformer extends TransformerAbstract
{
    public function transform(SunPicture $sunPicture)
    {
        $avatarUrl = "http://yuejian.app/uploads/avatars/";
        return [
            'post_id' => $sunPicture['id'],
            'posts_content' => $sunPicture['posts_content'],
            'comments_count' => $sunPicture['comments_count'],
            'posts_pic' => $avatarUrl.$sunPicture['posts_pic'],
            'user' => isset($sunPicture->user) ? $sunPicture->user:'Null',
            'post_comments'=>isset($sunPicture->comments)? $sunPicture->comments:'Null'
        ];
    }
}